home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 592 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: qcd.lanl.gov!tanmoy
  2. From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Binary Tree and MSC/C++7.00
  5. Date: 7 Jan 1996 17:37:39 GMT
  6. Organization: Los Alamos National Laboratory
  7. Distribution: world
  8. Message-ID: <4cp0d3$e75@newshost.lanl.gov>
  9. References: <HAKOLA.96Jan7002825@lk-hp-16.hut.fi>
  10. NNTP-Posting-Host: qcd.lanl.gov
  11.  
  12. In article <HAKOLA.96Jan7002825@lk-hp-16.hut.fi>, hakola@snakemail.hut.fi
  13. (Petri Hakola) writes: 
  14. |> 
  15. |>     It seems to me that I suffer some kind of partial amnesia. I
  16. |>     can build a binary tree, add stuff to it, but how do I destroy
  17. |>     it. I've tried nearly everyting, but there's either General
  18. |>     Protection Error or some remains of prior members. I have
  19. |>     quite embarassing feeling that I have forget something so
  20. |>     obvious that it should almost 'hit the eye', but...
  21. |> 
  22. |>         if(root == NULL)
  23. |>                   return;
  24. |>                 delete_tree(root->left);
  25. |>                   free(root);
  26. |>         delete_tree(root->right);
  27. |> 
  28. |>     Is this correct or ?
  29.  
  30. You cannot use `root' after you free it!!! So, your delete_tree(free->right)
  31. invokes undefined behaviour. You _must_ free root at the end.
  32.  
  33. |> 
  34. |>     And then some problems with strings. Is it common that while
  35. |>     coding using Microsoft Programmers Workbench, strings aren't
  36. |>     what they're supposed to be. For examble, if I use strncat to
  37. |>     cut string from 100 char to 45 char, string is cut, but if I
  38. |>     print it using printf, first 45 chars come out ok, but rest of
  39. |>     the string is filled with smiling faces and all sorts of
  40. |>     'exotic' characters. Like '\0' isn't there or something...
  41.  
  42. strncat is supposed to append a '\0'. Could you show some code?
  43.  
  44. Cheers
  45. Tanmoy
  46. -- 
  47. tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
  48. Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
  49. Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
  50. <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
  51. internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
  52. fax: 1 (505) 665 3003   voice: 1 (505) 665 4733    [ Home: 1 (505) 662 5596 ]
  53.